package cn.jiadakeji.parent.controller;

import cn.jiadakeji.parent.common.core.controller.BaseController;
import cn.jiadakeji.parent.common.core.domain.AjaxResult;
import cn.jiadakeji.parent.common.page.TableDataInfo;
import cn.jiadakeji.parent.dto.ClassCoursePrePlanDTO;
import cn.jiadakeji.parent.dto.ClassCoursePrePlanDetailsDTO;
import cn.jiadakeji.parent.service.ClassCoursePrePlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author heyanfeng
 * @create 2022-03-14 15:42
 */
@Api(value = "预开课信息", tags = {"预开课信息接口"})
@RestController
@RequestMapping("/coursePre")
public class ClassCoursePrePlanController extends BaseController {

    @Autowired
    private ClassCoursePrePlanService coursePrePlanService;

    @ApiOperation("获取学生预开课信息")
    @GetMapping("/coursePreWithId/{studentId}")
    public TableDataInfo coursePreList(
            @ApiParam("学生ID")
            @PathVariable("studentId") String studentId
    ) {
        startPage();
        List<ClassCoursePrePlanDTO> coursePrePlanDTOS = coursePrePlanService.coursePreList(studentId);
        return getDataTable(coursePrePlanDTOS);
    }

    @ApiOperation("预开课详细信息")
    @GetMapping("/coursePreDetail/{coursePreId}")
    public AjaxResult coursePreDetail(
            @ApiParam("预开课ID")
            @PathVariable("coursePreId") String coursePreId,
            @ApiParam("学生ID")
            @RequestParam("studentId") String studentId
    ) throws Exception {
        ClassCoursePrePlanDetailsDTO prePlanDetailsDTO = coursePrePlanService.coursePreDetail(coursePreId,studentId);
        return AjaxResult.success(prePlanDetailsDTO);
    }
}
